package com.djhu.newscollector.crawel.imp.forumdisplay;

import com.djhu.newscollector.core.Holder.JobHolder;
import com.djhu.newscollector.core.dispatch.JobDispatcher;
import com.djhu.newscollector.crawel.core.PageProcess;
import com.djhu.newscollector.crawel.core.ProcessMatcher;
import com.djhu.newscollector.crawel.core.Url;
import com.djhu.newscollector.crawel.imp.wangyi.DefaultPageProcess;

public class ForumProcessMatcher implements ProcessMatcher {
    private JobHolder jobHolder;

    private JobDispatcher jobDispatcher;

    @Override
    public PageProcess match(Url url) {
        String link = url.getUrl();
        if (link.contains("tid")){
            return new ImagePageProcess();
        }else if (link.contains("fid")){
            IndexPageProcess indexPageProcess = new IndexPageProcess();
            indexPageProcess.setJobDispatcher(jobDispatcher);
            indexPageProcess.setJobHolder(jobHolder);
            return indexPageProcess;
        }
        return new  DefaultPageProcess();
    }

    public JobHolder getJobHolder() {
        return jobHolder;
    }

    public void setJobHolder(JobHolder jobHolder) {
        this.jobHolder = jobHolder;
    }

    public JobDispatcher getJobDispatcher() {
        return jobDispatcher;
    }

    public void setJobDispatcher(JobDispatcher jobDispatcher) {
        this.jobDispatcher = jobDispatcher;
    }
}
